import { post, get } from "../../../utils/request";
import utils from "../../../utils/utils";
const env = import.meta.env;

const apiCms = {
  generateId(data?: object) {
    return get(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/id", data);
  },
  saveArticle(data: object) {
    return post(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/article.save", data);
  },
  deleteArticle(articleId: string) {
    return post(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/article.delete", {
      articleId: articleId,
    });
  },
  getArticle(articleId: string) {
    return get(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/article.get", {
      articleId: articleId,
    });
  },
  queryArticleListing(data?: object) {
    return post(
      env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/article.listing",
      data
    );
  },
  saveChannel(data: object) {
    return post(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/channel.save", data);
  },
  deleteChannel(channelId: string) {
    return post(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/channel.delete", {
      channelId: channelId,
    });
  },
  getChannel(channelId: string) {
    return get(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/channel.get", {
      channelId: channelId,
    });
  },
  queryChannelListing(data?: object) {
    return post(
      env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/channel.listing",
      data
    );
  },
  // loadAllChannel() {
  //   return get(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/channel.all", null);
  // },
  loadChannelJson() {
    return get(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/channel.json", null);
  },
  loadAllChannelJson() {
    return get(
      env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/channel.all.json",
      null
    );
  },
  queryTagListing(data?: object) {
    return post(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/tag.listing", data);
  },
  querySearchValueListing(data?: object) {
    return post(
      env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/search.value.listing",
      data
    );
  },
};

export default apiCms;
